package com.apes.importData.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.framework.plugin.soe.metadata.BusinessType;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @ClassName ImportModel
 * @Description TODO
 * @Author pengyb
 * @Date 2019/6/25 10:50
 * @Version 1.0
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ImportModel.CONST_TABLE_NAME, indexes = {
        @Index(columnList = "business_type,production_environment", unique = true)
})
public class ImportModel extends BaseModel {
    public static final String CONST_TABLE_NAME = "import_model";

    @Id
    @Column(name = "id", length = 16)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "导入模型对照表")
    private String id;

    @Comment("业务模型")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "business_type", referencedColumnName = "id", nullable = false)
    private BusinessType businessType;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "production_environment", referencedColumnName = "id")
    private Enumeration productionEnvironment;

}
